package com.atguigu.cos.controller;

import com.atguigu.commonutils.R;
import com.atguigu.cos.service.CosService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName : FileUploadController
 * @Author : 骆发茂
 * @Date: 2021/11/13 12:21
 * @Description : 上传头像
 */
@Api("腾讯云COS存储服务")
@CrossOrigin
@RestController
@RequestMapping("/educos//filecos")
public class FileUploadController {


    @Autowired
    public CosService cosService;

    //上传头像的方法
    @PostMapping
    public R uploadOssFile(MultipartFile file) {
        //获取上传文件  MultipartFile
        //返回上传到oss的路径
        String url = cosService.uploadFileAvatar(file);
        return R.ok().data("url",url);


}}